import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/achieves/archieves_ability_entity.dart';
import 'package:flutter_eve_plugin/route/main.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class ArchivesPersonCenterWidget extends StatelessWidget {
  final ArchievesAbilityEntity data;

  const ArchivesPersonCenterWidget({Key key, this.data}) : super(key: key);

  List<Widget> createItem(int len) {
    List<String> list = data.data.length > 0 ?
    data?.data[0]?.goodAtProperty : [];
    return List<Widget>.generate(len, (index) {
      return Padding(
        padding: EdgeInsets.only(right: setRatio(8)),
        child: Stack(children: [
          Image.asset(
            imageUtilYeXiu('archives/icon_archivers_ability_title_border@3x'),
            width: setRatio(90),
            height: setRatio(29),
          ),
          Container(
              width: setRatio(90),
              height: setRatio(29),
            child: Center(
              child : Text(
                '${list[index]}',
                style: TextStyle(
                    color: Color(0xFFFFFFFF),
                    fontSize: setTextSp(13)),
              ),
            )
          )
        ]),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.pushNamed(context, RouteConstant.ArchivesAbilityDetailsPage);
      },
      child: Container(
        width: setRatio(360),
        height: setRatio(130),
        margin: EdgeInsets.only(left: setRatio(7.5), top: setRatio(16)),
        decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage(imageUtilYeXiu(
                    'archives/icon_archivers_person_center_bg@3x')))),
        child: Stack(
          overflow: Overflow.visible,
          children: <Widget>[
            Container(
              width: setRatio(95),
              height: setRatio(26),
              margin: EdgeInsets.only(left: setRatio(6), top: setRatio(13)),
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage(imageUtilYeXiu(
                          'archives/icon_archivers_left_title_bg1@3x')))),
              child: Container(
                padding: EdgeInsets.only(left: setRatio(15), top: setRatio(3)),
                child: Text(
                  '擅长能力',
                  style: TextStyle(
                      shadows: [
                        BoxShadow(
                            color: Color(0x47000000),
                            offset: Offset(0, setRatio(2)),
                            blurRadius: setRatio(2))
                      ],
                      decoration: TextDecoration.none,
                      letterSpacing: 1,
                      color: Color(0xFFFFFFFF),
                      fontFamily: FontFamily.PMZD,
                      fontSize: setTextSp(15)),
                ),
              ),
            ),
            Positioned(
              right: setRatio(25),
              top: setRatio(13),
              child: Image.asset(
                imageUtilYeXiu('archives/icon_archivers_footer_more@3x'),
                width: setRatio(12),
                height: setRatio(20),
              ),
            ),
            Positioned(
              left: setRatio(14),
              bottom: setRatio(38),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: createItem(data.data.length > 0 ? data.data[0]?.goodAtProperty?.length : 0),
              ),
            )
          ],
        ),
      ),
    );
  }
}
